package com.itheima.d10_api_stringbuilder_use;

import cn.hutool.core.util.StrUtil;

/**
 * 目标：掌握StringBuidler/StringBuffer的使用场景
 */
public class Test {

    public static void main(String[] args) {
        //testString();
        //testStringBuilder();
        testHutoolBuilder();
    }

    private static void testHutoolBuilder() {
        long start = System.currentTimeMillis();

        StringBuilder sb = StrUtil.builder();

        for (int i = 0; i < 100000; i++) {
            sb.append("kunkun");
        }

        System.out.println(sb.toString());
        long end = System.currentTimeMillis();

        System.out.println("执行时间："+(end-start)/1000.0+"s");
    }



    private static void testStringBuilder() {
        long start = System.currentTimeMillis();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 100000; i++) {
            sb.append("kunkun");
        }

        System.out.println(sb.toString());
        long end = System.currentTimeMillis();

        System.out.println("执行时间："+(end-start)/1000.0+"s");
    }


    private static void testString() {
        long start = System.currentTimeMillis();
        String rs = "";
        for (int i = 0; i < 100000; i++) {
            rs += "kunkun";
        }

        System.out.println(rs);
        long end = System.currentTimeMillis();

        System.out.println("执行时间："+(end-start)/1000.0+"s");
    }
}
